package patrol.mobile.com.mobilepatrol.activity;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.utils.CommonUtil;

public class VideoPlayActivity extends BaseActivity {


    @BindView(R.id.video_view)
    VideoView videoView;
    private Uri mVideoUri;
    private String videopath = "";

    @Override
    public void initTitle() {
        super.initTitle();
        iv_back.setImageResource(R.mipmap.up_white);
        iv_back.setVisibility(View.VISIBLE);
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CommonUtil.exitActivityAndBackAnim(VideoPlayActivity.this, true);
            }
        });
        tv_center_title.setVisibility(View.VISIBLE);
        tv_center_title.setText("视频播放");

    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_video_play;
    }

    @Override
    public void setListener() {

    }

    @Override
    public void initData() {
        Intent intent = getIntent();
        if (null != intent) {
            videopath = intent.getStringExtra("videopath");
        }
        videoView.setMediaController(new MediaController(this));

        mVideoUri = Uri.parse(videopath);
        videoView.setVideoPath(mVideoUri.toString());
        videoView.start();
        videoView.requestFocus();
    }
}
